$(function () {
    findHome();
});

function findHome() {
    $.ajax({
        url: '/front/home',
        data: '',
        dataType: 'json',
        type: 'get',
        success: function (data) {
            console.log(data);
            setNewsData(data.newsModelList);
            setProductData();
        }
    })
}

function setNewsData(data) {
    let html = '';
    for (let i = 0; i < data.length; i++) {
        html += ' <div>\n' +
            '                            <div onclick="gotoNewsDetail(' + data[i].id + ')">' + data[i].title + '</div>\n' +
            '                            <div>' + data[i].content + '</div>\n' +
            '                        </div>';
    }
    $("#news").html(html);
}

function gotoNewsDetail(id) {
    sessionStorage.setItem("newsId",id);
    window.open("/front/newsDetail.html");
}

function setProductData() {

}